#include <STC15F2K60S2.H>
#include "Relay.h"
#include "Onewire.h"
#include "Delay.h"

#define WD_ZH 0XCC  //温度转换指令
#define TG_ROM 0X44  //跳过ROM
#define D_WD 0XBE  //读寄存器

void DS18B20_Convert(void)
{
	Onewire_Init();
	Write_Byte(TG_ROM);
	Write_Byte(WD_ZH);
}

float DS18B20_Read(void)
{
	unsigned char LSBT,MSBT;
	int Temp = 0;
	float b = 0;
	Onewire_Init();
	Write_Byte(TG_ROM);
	Write_Byte(D_WD);
	LSBT = Read_Byte();
	MSBT = Read_Byte();
	Temp=(MSBT<<8)|LSBT;
	b = Temp/16.0;
	return b;
}

void Show_t()
{
	unsigned int t = 0;
	DS18B20_Convert();
	t = DS18B20_Read();
	//t=(unsigned int)((T+0.05)*10);
	Nixie_Show(1,t/10);
	Delay(1);
	Nixie_Show(2,t%10);
}

void main()
{
	
	Latch_Init(0xa0,0x00);
	Latch_Init(0x80,0xcc);
	Show_t();
	while(1)
	{
		
	}
}
